<template>
    <div>
        
        <province-header>
        </province-header>
        <div class="provinceLeft">
            <left-contentOne   :option="option" :chart1Data="chart1Data" :chart2Data="chart2Data"></left-contentOne>
            <left-contentTwo   :HourBestCity="HourBestCity" :DayBestCity="DayBestCity" :MonthBestCity="MonthBestCity" :QuarterBestCity="QuarterBestCity"></left-contentTwo>
            <left-contentThree :CityStationQXDJCounts="CityStationQXDJCounts"></left-contentThree>   
        </div> 
        <right-tool></right-tool>
        <common-bottom></common-bottom>
        <common-controlBtn></common-controlBtn>
        <cesium-container :newArr1="newArr1" :newArr2="newArr2" :newArr4="newArr4">
        </cesium-container>
        <!-- <city-stationCount ></city-stationCount> -->
    </div>
</template>
<script>
import CesiumMarker from "./components/CesiumMarker"
import CesiumContainer from '../cesium/CesiumContainer'
import ProvinceHeader from './components/ProvinceHeader'
import RightTool from '../commons/RightTool'
import LeftContentOne from './components/LeftContentOne'
import LeftContentTwo from './components/LeftContentTwo'
import LeftContentThree from './components/LeftContentThree'
import CommonBottom from '../commons/CommonBottom'
import CommonControlBtn from '../commons/CommonControlBtn'
import HeaderCenter from '../commons/components/HeaderCenter'
import CityStationCount from './components/CityStationCount'
import axios from 'axios'
export default {
    name: 'Province',
    data(){
        return{
            timer:null,
            chart1Data:[],
            chart2Data:[],
            bestCityList:[],
            HourBestCity:{},
            DayBestCity:{},
            MonthBestCity:{},
            QuarterBestCity:{},
            cityName:[],
            bestChartsData:[],
            chartsCity:[],
            chartsList1:[],
            chartsList2:[],
            chartsList3:[],
            chartsList4:[],
            chartsList5:[],
            chartsList6:[],
            CityStationQXDJCounts:[],
            StationEPAdatas:[],
            markerArr1:[],
            objPopup:{},
            pointa: '',
            newArr1:[],
            newArr2:[],
            newArr4:[],
            option: [{
                value: 'zhinan',
                label: '杭州',
                children: [{value: 'shejiyuanze',label: '上城', children: [{value: 'yizhi',label: '馒头山'}, {value: 'fankui',label: '反馈'}]
                },{ value: 'daohang',
                    label: '临安',
                    children: [{
                      value: 'cexiangdaohang',
                      label: '柳溪江'
                    }, {
                      value: 'dingbudaohang',
                      label: '天目山'
                    }]
                  }]
              }, {
                value: 'zujian',
                label: '湖州',
                children: [{value: 'basic',
                  label: 'Basic',
                  children: [{
                    value: 'layout',
                    label: 'Layout 布局'
                  }, {
                    value: 'color',
                    label: 'Color 色彩'
                  }, {
                    value: 'typography',
                    label: 'Typography 字体'
                  }, {
                    value: 'icon',
                    label: 'Icon 图标'
                  }, {
                    value: 'button',
                    label: 'Button 按钮'
                  }]
                }, {
                  value: 'form',
                  label: 'Form',
                  children: [{
                    value: 'radio',
                    label: 'Radio 单选框'
                  }, {
                    value: 'checkbox',
                    label: 'Checkbox 多选框'
                  }, {
                    value: 'input',
                    label: 'Input 输入框'
                  }, {
                    value: 'input-number',
                    label: 'InputNumber 计数器'
                  }, {
                    value: 'select',
                    label: 'Select 选择器'
                  }, {
                    value: 'cascader',
                    label: 'Cascader 级联选择器'
                  }, {
                    value: 'switch',
                    label: 'Switch 开关'
                  }, {
                    value: 'slider',
                    label: 'Slider 滑块'
                  }, {
                    value: 'time-picker',
                    label: 'TimePicker 时间选择器'
                  }, {
                    value: 'date-picker',
                    label: 'DatePicker 日期选择器'
                  }, {
                    value: 'datetime-picker',
                    label: 'DateTimePicker 日期时间选择器'
                  }, {
                    value: 'upload',
                    label: 'Upload 上传'
                  }, {
                    value: 'rate',
                    label: 'Rate 评分'
                  }, {
                    value: 'form',
                    label: 'Form 表单'
                  }]
                }, {
                  value: 'data',
                  label: 'Data',
                  children: [{
                    value: 'table',
                    label: 'Table 表格'
                  }, {
                    value: 'tag',
                    label: 'Tag 标签'
                  }, {
                    value: 'progress',
                    label: 'Progress 进度条'
                  }, {
                    value: 'tree',
                    label: 'Tree 树形控件'
                  }, {
                    value: 'pagination',
                    label: 'Pagination 分页'
                  }, {
                    value: 'badge',
                    label: 'Badge 标记'
                  }]
                }, {
                  value: 'notice',
                  label: 'Notice',
                  children: [{
                    value: 'alert',
                    label: 'Alert 警告'
                  }, {
                    value: 'loading',
                    label: 'Loading 加载'
                  }, {
                    value: 'message',
                    label: 'Message 消息提示'
                  }, {
                    value: 'message-box',
                    label: 'MessageBox 弹框'
                  }, {
                    value: 'notification',
                    label: 'Notification 通知'
                  }]
                }, {
                  value: 'navigation',
                  label: 'Navigation',
                  children: [{
                    value: 'menu',
                    label: 'NavMenu 导航菜单'
                  }, {
                    value: 'tabs',
                    label: 'Tabs 标签页'
                  }, {
                    value: 'breadcrumb',
                    label: 'Breadcrumb 面包屑'
                  }, {
                    value: 'dropdown',
                    label: 'Dropdown 下拉菜单'
                  }, {
                    value: 'steps',
                    label: 'Steps 步骤条'
                  }]
                }, {
                  value: 'others',
                  label: 'Others',
                  children: [{
                    value: 'dialog',
                    label: 'Dialog 对话框'
                  }, {
                    value: 'tooltip',
                    label: 'Tooltip 文字提示'
                  }, {
                    value: 'popover',
                    label: 'Popover 弹出框'
                  }, {
                    value: 'card',
                    label: 'Card 卡片'
                  }, {
                    value: 'carousel',
                    label: 'Carousel 走马灯'
                  }, {
                    value: 'collapse',
                    label: 'Collapse 折叠面板'
                  }]
                }]
              }]

        }
    },
    components: {
        CesiumContainer,
        ProvinceHeader,
        LeftContentOne,
        LeftContentTwo,
        LeftContentThree,
        RightTool,
        CommonBottom,
        CommonControlBtn,
        HeaderCenter,
        CesiumMarker,
        CityStationCount
    },
    methods: {
        getProvinceData(){
          if(this.$comjs.isOnline){
            axios.get('/apis/api/FYLZ/GetFYLZProvinceInfo').then(res=>{
                    this.getProvinceDataInfo(res)
                }
            )
          }else{
            axios.get(this.$comjs.fylzPro).then(res=>{
                    this.getProvinceDataInfo(res)
                }
            )
          }
        },
        getProvinceDataInfo(res){
            
            //城市marker
            if(res.data.CityEPAdatas){
                this.newArr1 = res.data.CityEPAdatas;
            }
            if(res.data.CountryEPAdatas){
                this.newArr4 = res.data.CountryEPAdatas;
            }
            if(res.data.StationEPAdatas){
                this.newArr2 = res.data.StationEPAdatas;
            }
            //最优城市
            if(res.data.HourBestCity){
              this.HourBestCity=res.data.HourBestCity;
            }
            if(res.data.DayBestCity){
              this.DayBestCity=res.data.DayBestCity;
            }
            if(res.data.MonthBestCity){
               this.MonthBestCity=res.data.MonthBestCity;
            }
            if(res.data.QuarterBestCity){
              this.QuarterBestCity=res.data.QuarterBestCity;
            }
            //城市站点个数
            if(res.data.CityStationQXDJCounts){
              this.CityStationQXDJCounts = res.data.CityStationQXDJCounts;
            }
            if(res.data.StationTypeCounts){
              this.chart1Data = res.data.StationTypeCounts
            }
            if(res.data.StationQXDJCounts){
              this.chart2Data = res.data.StationQXDJCounts
            }
            if(res.data.StationEPAdatas){
              this.StationEPAdatas = res.data.StationEPAdatas
            }
            if(res.data.FYLZCounts){
              this.$store.commit("getFYLZCounts",res.data.FYLZCounts);
              localStorage.setItem('FYLZCounts', JSON.stringify(res.data.FYLZCounts));
            }
            if(res.data.TOP10FYLZCounts){
              this.$store.commit("getTOP10FYLZCounts",res.data.TOP10FYLZCounts)
            }
            if(res.data.Regions){
              this.$store.commit("changeCities",res.data.Regions)
            }
            
            
        },
        handleClickCity(){
            this.$store.commit('changeCityName', this.shisList[index].name)
                localStorage.setItem('cityX', this.shisList[index].x);
                localStorage.setItem('cityY', this.shisList[index].y);
            this.$router.push('/city/' + localStorage.headerCity)
        },
        andUpdata(){
          //在整点执行的函数，在每个整点都调用该函数
          this.getProvinceData()
          this.timer = setInterval(()=>{
            this.getProvinceData()
          },60*60*1000);//一个小时执行一次，那么下一个整点，下下一个整点都会执行
        }
    },
    activated(){
        this.$store.commit("changeForq",0)
    },
    beforeMount(){
        this.$store.commit("changeForq",0);
        // this.$store.commit("changeState",1)
    },
    beforeDestroy(){
      if(this.timer){
          clearInterval(this.timer)
        }
    },
    mounted(){
        //添加负氧离子marker
        // this.$comjs.addF();
        //异步获取有问题.采用promise .then
        //当前组件调用当前axios返回值，是异步
        this.getProvinceData(); 
        var date = new Date();//现在时刻
        var dateIntegralPoint = new Date();//用户登录时刻的下一个整点，也可以设置成某一个固定时刻
        dateIntegralPoint.setHours(date.getHours()+1);//小时数增加1
        dateIntegralPoint.setMinutes(10);
        dateIntegralPoint.setSeconds(0);
        console.log(dateIntegralPoint);
        console.log(dateIntegralPoint-date);
        console.log((dateIntegralPoint-date)/60000);
        setTimeout(()=>{this.andUpdata()},dateIntegralPoint-date);//用户登录后的整点十分执行。
        // this.timer = setInterval(()=>{
        //     this.getProvinceData()
        // },3600000)
        // setTimeout(()=>{
        //     this.bindCityMarker();
        // },2000)
        //此处无法获取viewer对象 console.log(this.$comjs.viewer)
        //设置一定的时间差，来操作dom
        // setTimeout(function(){
        //     $('div[id^="popup-fylzStation"]').hide();
        // },200)
        
        // this.$comjs.changeGEOJson(0)
            
        
    }
}
</script>
<style>
    .provinceLeft{
        position: absolute;
        left: 0;
        top: 6.57vh;
        z-index: 2;
        width: 4.02rem;
        /*height: calc(100% - 1.32rem); 12.2vh*/
        height: 87.8vh;
    }
</style>

